//
//  DZAFNetworkingBase.h
//  DZToolbox
//
//  Created by Darren on 15/5/12.
//  Copyright (c) 2015年 Darren Zheng. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AFNetworking.h"

@interface DZNetworkBase : NSObject

/**
 *  URL头, URL共性部分
 *  @note overwrite(required)
 */
- (NSString *)strURLHeader;

/**
 *  成功分支 dict[strSuccessKey] == strSuccessValue 则表示成功，
 *  否则失败，失败则提示dict[strErrorMessageKey]
 *  @note overwrite(optional)
 */
- (NSString *)strSuccessKey;
- (NSString *)strSuccessValue;
- (NSString *)strErrorMessageKey;

/**
 *  对应Content-Type，默认为text/html
 *  @note overwrite(optional)
 */
- (NSString *)strContentType;

/**
 *  Header
 *  @note overwrite(optional)
 */
- (NSDictionary *)dictHeader;

/**
 *  timeout
 *  @note overwrite(optional)
 */
- (float)fTimeoutSec;


/**
 *  GET
 *
 *  @param strURL         URL后半段
 *  @param mDictParams    post参数
 *  @param blockSuccess   成功回调
 *  @param blockFailure   失败回调
 */
- (void)getWithURLString:(NSString *)strURL
                  params:(NSMutableDictionary *)mDictParams
                 success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))blockSuccess
                 failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))blockFailure;

/**
 *  GET图片专用
 *
 *  @param strURL         URL后半段
 *  @param mDictParams    post参数
 *  @param blockSuccess   成功回调
 *  @param blockFailure   失败回调
 */
- (void)getImageWithURLString:(NSString *)strURL
                       params:(NSMutableDictionary *)mDictParams
                      success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))blockSuccess
                      failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))blockFailure;

/**
 *  POST (URL-Form-Encoded)
 *
 *  @param strURL         URL后半段
 *  @param mDictParams    post参数
 *  @param arrayImages    UIImages
 *  @param blockSuccess   成功回调
 *  @param blockFailure   失败回调
 */
- (void)postWithURLString:(NSString *)strURL
                   params:(NSMutableDictionary *)mDictParams
                  success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))blockSuccess
                  failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))blockFailure;
/**
 *  Multi-Part Request (文件/图片上传)
 *
 *  @param strURL         URL后半段
 *  @param mDictParams    post参数
 *  @param arrayImages    UIImages
 *  @param blockSuccess   成功回调
 *  @param blockFailure   失败回调
 */
- (void)uploadWithURLString:(NSString *)strURL
                     params:(NSMutableDictionary *)mDictParams
                     images:(NSArray *)arrayImages
                   filename:(NSString *)name
                    success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))blockSuccess
                    failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))blockFailure;
/**
 *  文件下载
 *
 *  @param strURL        URL后半段
 *  @param mDictParams   post参数
 *  @param blockSuccess  成功回调
 *  @param blockFailure  失败回调
 *  @param blockProgress 进度回调
 */
- (void)downloadWithURLString:(NSString *)strURL
                       params:(NSMutableDictionary *)mDictParams
                      success:(void (^)(AFHTTPRequestOperation *operation, id responseObject, NSString *strFilePath))blockSuccess
                      failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))blockFailure
                     progress:(void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))blockProgress;



@end
